using System;
using System.Collections.Generic;
using System.Text;

namespace CommonTypes.Math.Sets
{
    public class Set<T> : List<T>, ICloneable
    {

        public virtual Set<T> Union(Set<T> set)
        {
            //  foreach ( T type in set )

            this.AddRange(set);

            return null;
        }
        public virtual Set<T> Disjaction(Set<T> set)
        {
            // Set<T> dis = new Set<T>();

            foreach (T type in this)
                if (set.Contains(type))
                    this.Remove(type);

            return null;
        }
        public virtual Set<T> Differance(Set<T> set)
        {
            Set<T> diff = (Set<T>)this.Clone();

            foreach (T type in set)
                if (diff.Contains(type))
                    diff.Remove(type);
            return diff;
        }
        public virtual bool IsEmty()
        {
            if (this.Count == 0)
                return true;
            return false;
        }

        #region ICloneable Members

        public virtual object Clone()
        {
            Set<T> newSet = (Set<T>)Activator.CreateInstance(this.GetType());
            newSet.AddRange(this);
            return newSet;
            /*
            Set<T> set = new Set<T>();
            set.AddRange(this);
            return set;
             * 
             * 
             */
        }

        #endregion
    }
    public class EmptySet<T> : Set<T>
    {
        private static Set<T> instance;
        public static Set<T> Instance
        {
            get
            {
                if (instance == null)
                    instance = new Set<T>();
                return instance;
            }
        }

        public override bool IsEmty()
        {
            return true;
        }


    }
}
